package com.codermn.demo10;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

/**
 * @author jxau_scf
 * @date 2021/6/30 - 17:03
 */
public class ReflectTest {
    public static void main(String[] args) throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException {
        Properties properties = new Properties();
        ClassLoader classLoader = ReflectTest.class.getClassLoader();
        InputStream is = classLoader.getResourceAsStream("com/codermn/demo10/test.properties");
        properties.load(is);
        String className = properties.getProperty("className");
        String methodName = properties.getProperty("methodName");
        Class<?> clazz = Class.forName(className);
        Object obj = clazz.newInstance();
        Method method = clazz.getMethod(methodName, String.class);
        method.invoke(obj, "哈哈哈");
    }
}
